package com.proxyadvertise.parse;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;

public class UserAgent {
	private static List<String> USER_AGENT_LIST = new ArrayList<String>();
	
	public static void parse() throws Exception{
		
		String userAgentFile = ProxyIp.class.getResource( "/UserAgent.txt" ).getPath();
		try {
			userAgentFile = URLDecoder.decode( userAgentFile, "utf-8" );
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		
		FileReader fr=new FileReader( userAgentFile );
        BufferedReader br=new BufferedReader(fr);
        String line="";
       
        while ((line=br.readLine())!=null) {
        	UserAgent.USER_AGENT_LIST.add( line.trim() );
        }
        br.close();
        fr.close();
        
	}
	
	public static List<String> getAllUserAgent(){
		return UserAgent.USER_AGENT_LIST;
	}
	
}
